From: Paul Donald Date: Mon, 31 Mar 2025 19:41:11 +0000 (+0200) Subject: luci-app-firewall: repair handleAdd for rules.js X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22/%22https:/collectd.org/%22?a=commitdiff_plain;h=d356e30ac13cc1648045d8a0bcb5dd92630778f4;p=project%2Fluci.git luci-app-firewall: repair handleAdd for rules.js handleAdd did not work correctly for a while: the defaults were not propagated, and some state was not cleaned up (try: firewall rules -> add -> no changes -> click dismiss -> press save). The state is now properly removed when pressing dismiss, by stashing addedSection correctly under the map m and not in this. Signed-off-by: Paul Donald --- diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js index c4383f268f..95b91b5445 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js @@ -192,19 +192,14 @@ return view.extend({ }; s.handleAdd = function(ev) { - var config_name = this.uciconfig || this.map.config, - section_id = uci.add(config_name, this.sectiontype), - opt1 = this.getOption('src'), - opt2 = this.getOption('dest'); + const config_name = this.uciconfig || this.map.config; + const section_id = uci.add(config_name, this.sectiontype); - opt1.default = 'wan'; - opt2.default = 'lan'; + uci.set(config_name, section_id, 'src', 'wan'); + uci.set(config_name, section_id, 'dest', 'lan'); - this.addedSection = section_id; + m.addedSection = section_id; this.renderMoreOptionsModal(section_id); - - delete opt1.default; - delete opt2.default; }; o = s.taboption('general', form.Value, 'name', _('Name'));